package com.fzz.controller;

import com.fzz.domain.User;
import com.fzz.service.UserService;
import com.fzz.serviceImpl.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;

import javax.servlet.http.HttpSession;

@Controller
public class UserController {

    @Autowired
    private UserService userService=new UserServiceImpl();
    @PostMapping(value = "/user/login")
    public String userLogin(HttpSession session,String username,String password)
    {
        User user = userService.userLogin(username, password);
        if(user!=null)
        {
            session.setAttribute("user",user);
            return "admin";
        }
        else
        {
            return "redirect:index";
        }
    }
}
